{% extends "myadmin/base.html" %}

{% block mainbody %}                
    <link rel="stylesheet" type="text/css" href="/ueditor/UE/third-party/SyntaxHighlighter/shCoreDefault.css">
    <script type="text/javascript" src="/ueditor/UE/third-party/SyntaxHighlighter/shCore.js"></script>
    <script type="text/javascript" src="/ueditor/UE/ueditor.config.js"></script>
    <script type="text/javascript" src="/ueditor/UE/ueditor.all.min.js"></script>
    <script type="text/javascript" src="/ueditor/UE/lang/zh-cn/zh-cn.js"></script>
    <h3>
        商品信息管理
    </h3>
    <form id="edit-profile" action="{% url 'myadmin_goods_update' goods.id %}" class="form-horizontal" method="post" enctype="multipart/form-data">
        {% csrf_token %}
        <input type="hidden" name="oldpicname" value="{{ goods.picname }}"/>
        <fieldset>
            <legend>查看/编辑商品信息</legend>
            <div class="control-group">
                <label class="control-label" for="input01">商品类别：</label>
                <div class="controls">
                    <select name="typeid">
                        {% for vo in typelist %}
                            <option 
                                {% if vo.pid == 0 %}
                                    disabled
                                {% endif %}

                                {% if vo.id == goods.typeid %}
                                    selected 
                                {% endif %}
                                 value="{{ vo.id }}">{{vo.pname}}|--{{ vo.name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">商品名称：</label>
                <div class="controls">
                    <input type="text" name="goods" value="{{ goods.goods }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">生产厂家：</label>
                <div class="controls">
                    <input type="text" name="company" value="{{ goods.company }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">单价：</label>
                <div class="controls">
                    <input type="text" name="price" value="{{ goods.price }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">库存量：</label>
                <div class="controls">
                    <input type="text" name="store" value="{{ goods.store }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">销售量：</label>
                <div class="controls">
                    <input type="text" disabled name="num" value="{{ goods.num }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">点击次数：</label>
                <div class="controls">
                    <input type="text" disabled name="clicknum" value="{{ goods.clicknum }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">添加时间：</label>
                <div class="controls">
                    <input type="text" disabled name="addtime" value="{{ goods.addtime|date:'Y-m-d H:i:s' }}" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">商品图片：</label>
                <div class="controls">
                    <input type="file" name="pic" class="input-xlarge" id="input01"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="input01">状态：</label>
                <div class="controls">
                    <input type="radio" name="state" class="input-xlarge" id="input01" 
                    {% if goods.state == 1 %}
                        checked  
                    {% endif %}
                    value="1" /> 新商品 
                    <input type="radio" name="state" class="input-xlarge" id="input01" 
                    {% if goods.state == 2 %}
                        checked  
                    {% endif %}
                    value="2" /> 在售
                    <input type="radio" name="state" class="input-xlarge" id="input01" 
                    {% if goods.state == 3 %}
                        checked  
                    {% endif %}
                    value="3" /> 已下架
                </div>
            </div>    
            <div class="control-group">
                <label class="control-label" for="input01">商品简介：</label>
                <div class="controls">
                    <script id="editor" name="content" type="text/plain" style="height:500px;">{{ goods.content|safe }}</script>

                </div>
            </div>                        
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">保存</button> <button type="reset" class="btn">重置</button>
            </div>
        </fieldset>
    </form>
    <br/>
    <div class="row">
        <div class="span5 offset2">
            <img src="/static/goods/m_{{ goods.picname }}"/>
        </div>
    </div>
    <script type="text/javascript">
        var ue = UE.getEditor('editor');
        SyntaxHighlighter.all();
    </script>
{% endblock %}